/*
 * Project: BooEditor
 * Author:  Johannes Kuhaupt
 * Last Change:
 *    by:   $Author: $
 *    date: $Date:   $
 * Copyright (c): Johannes Kuhaupt
 * Licence: Creative Commons CC BY-NC-SA 3.0
 */
package view;

import control.FileManager;
import control.GuiManager;
import control.SettingsManager;
import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.event.KeyEvent;
import java.awt.print.PrinterException;
import java.io.File;
import java.net.MalformedURLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.KeyStroke;
import org.lobobrowser.gui.FramePanel;
import org.lobobrowser.main.PlatformInit;



/**
 *
 * @author Jojo
 */
public class MainFrame extends javax.swing.JFrame {

    private static MainFrame instance = null;
    CustomTabPanel activeTab;
    java.util.ResourceBundle langBundle = GuiManager.getLangBundle();
    FramePanel browser = new FramePanel();

    /**
     * Creates new form BooEditorMainFrame
     *
     * @param pFile
     * @param pGuiMan
     */
    private MainFrame() {
        initComponents();
        initToolbarAndStatusbar();
        this.addComponentListener(new ResizeListener(this));
        
//        this.tabEditorDocuments.add(editor);
        
        this.initKeyShortcuts();
        //Icon
        Image icon = new ImageIcon(getClass().getResource("/icons/html.png")).getImage();
        this.setIconImage(icon);
        this.browserTab.add(browser);
        this.browserTab.setTitleAt(0, langBundle.getString("Preview"));

        try {
            PlatformInit.getInstance().initLogging(false);

            // This step is necessary for extensions to work:
            PlatformInit.getInstance().init(false, false);
            this.browser.navigate(getClass().getResource("/ressources/startPage.html"));
        } catch (Exception ex) {
            Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
        }





        pack();
    }

    private void initToolbarAndStatusbar() {
        this.initToolbar();
        this.initStatusbar();
    }

    private void initStatusbar() {
        this.panelStatusBar.setPreferredSize(new Dimension(this.lbl_statusbarFilePath.getPreferredSize().width,
                this.lbl_statusbarFilePath.getPreferredSize().height + 5));
        this.lbl_statusbarFilePath.setText(this.lbl_statusbarFilePath.getText() + " "
                + langBundle.getString("MsgInfoNewFile"));
    }

    private void initToolbar() {
        //Toolbar
        this.toolbar.setFloatable(false);


        // ToolbarButtons
        int width = 55;
        int height = 45;
        int extra = 8;
        this.btn_newFile.setMinimumSize(new Dimension(width, height));
        this.btn_newFile.setMaximumSize(new Dimension(width, height));
        this.btn_newFile.setSize(new Dimension(width, height));
        this.btn_newFile.setPreferredSize(new Dimension(width, height));


        this.btn_openFile.setMinimumSize(new Dimension(width, height));
        this.btn_openFile.setMaximumSize(new Dimension(width, height));
        this.btn_openFile.setSize(new Dimension(width, height));
        this.btn_openFile.setPreferredSize(new Dimension(width, height));

        this.btn_close.setMinimumSize(new Dimension(width, height));
        this.btn_close.setMaximumSize(new Dimension(width, height));
        this.btn_close.setSize(new Dimension(width, height));
        this.btn_close.setPreferredSize(new Dimension(width, height));





        this.btn_copy.setMinimumSize(new Dimension(width, height));
        this.btn_copy.setMaximumSize(new Dimension(width, height));
        this.btn_copy.setSize(new Dimension(width, height));
        this.btn_copy.setPreferredSize(new Dimension(width, height));

        this.btn_paste.setMinimumSize(new Dimension(width, height));
        this.btn_paste.setMaximumSize(new Dimension(width, height));
        this.btn_paste.setSize(new Dimension(width, height));
        this.btn_paste.setPreferredSize(new Dimension(width, height));

        this.btn_save.setMinimumSize(new Dimension(width, height));
        this.btn_save.setMaximumSize(new Dimension(width, height));
        this.btn_save.setSize(new Dimension(width, height));
        this.btn_save.setPreferredSize(new Dimension(width, height));



        this.btn_uploadAction.setMinimumSize(new Dimension(width + extra, height));
        this.btn_uploadAction.setMaximumSize(new Dimension(width + extra, height));
        this.btn_uploadAction.setSize(new Dimension(width + extra, height));
        this.btn_uploadAction.setPreferredSize(new Dimension(width + extra, height));

        this.btn_startBooAction.setMinimumSize(new Dimension(width + extra, height));
        this.btn_startBooAction.setMaximumSize(new Dimension(width + extra, height));
        this.btn_startBooAction.setSize(new Dimension(width + extra, height));
        this.btn_startBooAction.setPreferredSize(new Dimension(width + extra, height));
    }

    public void initKeyShortcuts() {
        this.mItem_newFile.setAccelerator(KeyStroke.getKeyStroke(
                KeyEvent.VK_N, KeyEvent.CTRL_DOWN_MASK));
        this.mItem_openFile.setAccelerator(KeyStroke.getKeyStroke(
                KeyEvent.VK_O, KeyEvent.CTRL_DOWN_MASK));
        this.mItem_closeFile.setAccelerator(KeyStroke.getKeyStroke(
                KeyEvent.VK_W, KeyEvent.CTRL_DOWN_MASK));
        this.mItem_saveFile.setAccelerator(KeyStroke.getKeyStroke(
                KeyEvent.VK_S, KeyEvent.CTRL_DOWN_MASK));
        this.mItem_saveFileAs.setAccelerator(KeyStroke.getKeyStroke(
                KeyEvent.VK_S, KeyEvent.CTRL_MASK + KeyEvent.SHIFT_MASK));
        this.mItem_printFile.setAccelerator(KeyStroke.getKeyStroke(
                KeyEvent.VK_P, KeyEvent.CTRL_DOWN_MASK));
        this.mItem_help.setAccelerator(KeyStroke.getKeyStroke(
                KeyEvent.VK_F1, 0));
        this.mItem_exit.setAccelerator(KeyStroke.getKeyStroke(
                KeyEvent.VK_F4, KeyEvent.ALT_DOWN_MASK));
        this.btn_newFile.setMnemonic('N');

    }

    public static MainFrame getInstance() {
        if (instance == null) {
            instance = new MainFrame();
        }
        return instance;
    }

    /**
     *
     */
    public void setStandardView() {
        this.setSize(new Dimension(800, 500));
        this.setLocationRelativeTo(null);
    }

    /**
     *
     */
    public void readSettingAndUpdateView() {
        this.setSize(new Dimension(SettingsManager.getIntSettingValue("FRAMEWIDTH"), SettingsManager.getIntSettingValue("FRAMEHEIGHT")));
        this.setLocation(SettingsManager.getIntSettingValue("FRAMEPOSITIONX"), SettingsManager.getIntSettingValue("FRAMEPOSITIONY"));



        this.repaint();
    }

    public void setInfoTextStatusBar(String pText) {
        this.lbl_statusbarFilePath.setText(pText);
    }

    /**
     *
     */
    public void saveNewViewSettings() {
        SettingsManager.updateSettingsItem("FRAMEWIDTH", this.getWidth() + "");
        SettingsManager.updateSettingsItem("FRAMEHEIGHT", this.getHeight() + "");
        SettingsManager.updateSettingsItem("FRAMEPOSITIONX", ((int) this.getLocationOnScreen().x) + "");
        SettingsManager.updateSettingsItem("FRAMEPOSITIONY", ((int) this.getLocationOnScreen().y) + "");
    }

    private void handleCloseFileAction() {
        this.activeTab.handleCloseFileAction();
    }

    private void handleOpenFileAction() {
        this.activeTab.handleOpenFileAction();
    }

    private void handleNewFileAction() {
        this.activeTab.handleNewFileAction();
    }

    public void setTabTitle(String pTabTitle) {
        this.tabEditorDocuments.setTitleAt(this.tabEditorDocuments.getSelectedIndex(), pTabTitle);
    }

    private void handleSaveFileAction() {

        this.activeTab.handleSaveFileAction();

    }

    /**
     *
     * @param pText
     */
    public void createNewTab(String pTitle, JPanel pTabPanel) {
        tabEditorDocuments.addTab(pTitle, new javax.swing.ImageIcon(getClass().getResource("/icons/page_white_wrench.png")), pTabPanel);
        tabEditorDocuments.setSelectedIndex(this.tabEditorDocuments.getTabCount() - 1);
        this.activeTab = (CustomTabPanel) tabEditorDocuments.getSelectedComponent();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPopupMenu1 = new javax.swing.JPopupMenu();
        menu_File1 = new javax.swing.JMenu();
        mItem_newFile = new javax.swing.JMenuItem();
        mItem_openFile = new javax.swing.JMenuItem();
        mItem_closeFile = new javax.swing.JMenuItem();
        jSeparator3 = new javax.swing.JPopupMenu.Separator();
        mItem_saveFile = new javax.swing.JMenuItem();
        mItem_saveFileAs = new javax.swing.JMenuItem();
        jSeparator4 = new javax.swing.JPopupMenu.Separator();
        mItem_printFile = new javax.swing.JMenuItem();
        jSeparator5 = new javax.swing.JPopupMenu.Separator();
        mItem_exit = new javax.swing.JMenuItem();
        menu_Edit = new javax.swing.JMenu();
        menu_undo = new javax.swing.JMenuItem();
        menu_redo = new javax.swing.JMenuItem();
        menu_copy = new javax.swing.JMenuItem();
        menu_paste = new javax.swing.JMenuItem();
        menu_cut = new javax.swing.JMenuItem();
        menu_selectAll = new javax.swing.JMenuItem();
        menu_Edit1 = new javax.swing.JMenu();
        menu_Help = new javax.swing.JMenu();
        mItem_about = new javax.swing.JMenuItem();
        mItem_help = new javax.swing.JMenuItem();
        contextMenuOptions = new javax.swing.JPopupMenu();
        mItemBigFont = new javax.swing.JMenuItem();
        mItem_EditorOptions = new javax.swing.JMenuItem();
        mItem_printFile1 = new javax.swing.JMenuItem();
        mItem_about1 = new javax.swing.JMenuItem();
        mItem_exit1 = new javax.swing.JMenuItem();
        toolbar = new javax.swing.JToolBar();
        btn_newFile = new javax.swing.JButton();
        btn_openFile = new javax.swing.JButton();
        btn_save = new javax.swing.JButton();
        btn_saveAs = new javax.swing.JButton();
        btn_close = new javax.swing.JButton();
        filler2 = new javax.swing.Box.Filler(new java.awt.Dimension(10, 0), new java.awt.Dimension(10, 0), new java.awt.Dimension(10, 32767));
        btn_undo = new javax.swing.JButton();
        btn_redo = new javax.swing.JButton();
        filler3 = new javax.swing.Box.Filler(new java.awt.Dimension(10, 0), new java.awt.Dimension(10, 0), new java.awt.Dimension(10, 32767));
        btn_copy = new javax.swing.JButton();
        btn_paste = new javax.swing.JButton();
        filler4 = new javax.swing.Box.Filler(new java.awt.Dimension(15, 0), new java.awt.Dimension(15, 0), new java.awt.Dimension(15, 32767));
        filler6 = new javax.swing.Box.Filler(new java.awt.Dimension(3, 0), new java.awt.Dimension(3, 0), new java.awt.Dimension(3, 32767));
        btn_convertUml = new javax.swing.JButton();
        filler11 = new javax.swing.Box.Filler(new java.awt.Dimension(15, 0), new java.awt.Dimension(15, 0), new java.awt.Dimension(15, 32767));
        filler12 = new javax.swing.Box.Filler(new java.awt.Dimension(3, 0), new java.awt.Dimension(3, 0), new java.awt.Dimension(3, 32767));
        btn_startBooAction = new javax.swing.JButton();
        btn_uploadAction = new javax.swing.JButton();
        filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 0));
        btn_options = new javax.swing.JButton();
        panelStatusBar = new javax.swing.JPanel();
        lbl_statusbarFilePath = new javax.swing.JLabel();
        jSplitPane1 = new javax.swing.JSplitPane();
        jPanel1 = new javax.swing.JPanel();
        filler14 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 15), new java.awt.Dimension(0, 15), new java.awt.Dimension(32767, 15));
        tabEditorDocuments = new javax.swing.JTabbedPane();
        jPanel2 = new javax.swing.JPanel();
        filler15 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 15), new java.awt.Dimension(0, 15), new java.awt.Dimension(32767, 15));
        browserTab = new javax.swing.JTabbedPane();

        menu_File1.setText(langBundle.getString("File"));
        menu_File1.setToolTipText(langBundle.getString("TT_File"));

        mItem_newFile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/page.png"))); // NOI18N
        mItem_newFile.setText(langBundle.getString("NewFile"));
        mItem_newFile.setToolTipText(langBundle.getString("TT_NewFile"));
        mItem_newFile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mItem_newFileActionPerformed(evt);
            }
        });
        menu_File1.add(mItem_newFile);

        mItem_openFile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/folder_page.png"))); // NOI18N
        mItem_openFile.setText(langBundle.getString("OpenFile"));
        mItem_openFile.setToolTipText(langBundle.getString("TT_OpenFile"));
        mItem_openFile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mItem_openFileActionPerformed(evt);
            }
        });
        menu_File1.add(mItem_openFile);

        mItem_closeFile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/page_delete.png"))); // NOI18N
        mItem_closeFile.setText(langBundle.getString("CloseFile"));
        mItem_closeFile.setToolTipText(langBundle.getString("TT_CloseFile"));
        mItem_closeFile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mItem_closeFileActionPerformed(evt);
            }
        });
        menu_File1.add(mItem_closeFile);
        menu_File1.add(jSeparator3);

        mItem_saveFile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/page_save.png"))); // NOI18N
        mItem_saveFile.setText(langBundle.getString("SaveFile"));
        mItem_saveFile.setToolTipText(langBundle.getString("TT_SaveFile"));
        mItem_saveFile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mItem_saveFileActionPerformed(evt);
            }
        });
        menu_File1.add(mItem_saveFile);

        mItem_saveFileAs.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/page_save.png"))); // NOI18N
        mItem_saveFileAs.setText(langBundle.getString("SaveAs"));
        mItem_saveFileAs.setToolTipText(langBundle.getString("TT_SaveFileAs"));
        mItem_saveFileAs.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mItem_saveFileAsActionPerformed(evt);
            }
        });
        menu_File1.add(mItem_saveFileAs);
        menu_File1.add(jSeparator4);

        mItem_printFile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/printer.png"))); // NOI18N
        mItem_printFile.setText(langBundle.getString("Print"));
        mItem_printFile.setToolTipText(langBundle.getString("TT_Print"));
        mItem_printFile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mItem_printFileActionPerformed(evt);
            }
        });
        menu_File1.add(mItem_printFile);
        menu_File1.add(jSeparator5);

        mItem_exit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/door_out.png"))); // NOI18N
        mItem_exit.setText(langBundle.getString("Exit"));
        mItem_exit.setToolTipText(langBundle.getString("TT_Exit"));
        mItem_exit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mItem_exitActionPerformed(evt);
            }
        });
        menu_File1.add(mItem_exit);

        jPopupMenu1.add(menu_File1);

        menu_Edit.setText(langBundle.getString("Edit"));

        menu_undo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/arrow_undo.png"))); // NOI18N
        menu_undo.setText("Rückgängig");
        menu_undo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menu_undoActionPerformed(evt);
            }
        });
        menu_Edit.add(menu_undo);

        menu_redo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/arrow_redo.png"))); // NOI18N
        menu_redo.setText("Wiederholen");
        menu_redo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menu_redoActionPerformed(evt);
            }
        });
        menu_Edit.add(menu_redo);

        menu_copy.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/page_copy.png"))); // NOI18N
        menu_copy.setText("Kopieren");
        menu_copy.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menu_copyActionPerformed(evt);
            }
        });
        menu_Edit.add(menu_copy);

        menu_paste.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/page_paste.png"))); // NOI18N
        menu_paste.setText("Einfügen");
        menu_paste.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menu_pasteActionPerformed(evt);
            }
        });
        menu_Edit.add(menu_paste);

        menu_cut.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/cut.png"))); // NOI18N
        menu_cut.setText("Ausschneiden");
        menu_cut.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menu_cutActionPerformed(evt);
            }
        });
        menu_Edit.add(menu_cut);

        menu_selectAll.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/text_align_left.png"))); // NOI18N
        menu_selectAll.setText("Alles auswählen");
        menu_selectAll.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menu_selectAllActionPerformed(evt);
            }
        });
        menu_Edit.add(menu_selectAll);

        jPopupMenu1.add(menu_Edit);

        menu_Edit1.setText(langBundle.getString("Options"));
        jPopupMenu1.add(menu_Edit1);

        menu_Help.setText("?");

        mItem_about.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/information.png"))); // NOI18N
        mItem_about.setText(langBundle.getString("About"));
        mItem_about.setToolTipText(langBundle.getString("TT_About"));
        mItem_about.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mItem_aboutActionPerformed(evt);
            }
        });
        menu_Help.add(mItem_about);

        mItem_help.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/help.png"))); // NOI18N
        mItem_help.setText(langBundle.getString("Help"));
        mItem_help.setToolTipText(langBundle.getString("TT_Help"));
        mItem_help.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mItem_helpActionPerformed(evt);
            }
        });
        menu_Help.add(mItem_help);

        jPopupMenu1.add(menu_Help);

        mItemBigFont.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/magnifier.png"))); // NOI18N
        mItemBigFont.setText(langBundle.getString("BigScreenModus"));
        mItemBigFont.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mItemBigFontActionPerformed(evt);
            }
        });
        contextMenuOptions.add(mItemBigFont);

        mItem_EditorOptions.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/wrench_orange.png"))); // NOI18N
        mItem_EditorOptions.setText(langBundle.getString("EditorOptions"));
        mItem_EditorOptions.setToolTipText(langBundle.getString("TT_OptionsEditor"));
        mItem_EditorOptions.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mItem_EditorOptionsActionPerformed(evt);
            }
        });
        contextMenuOptions.add(mItem_EditorOptions);

        mItem_printFile1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/printer.png"))); // NOI18N
        mItem_printFile1.setText(langBundle.getString("Print"));
        mItem_printFile1.setToolTipText(langBundle.getString("TT_Print"));
        mItem_printFile1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mItem_printFile1ActionPerformed(evt);
            }
        });
        contextMenuOptions.add(mItem_printFile1);

        mItem_about1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/information.png"))); // NOI18N
        mItem_about1.setText(langBundle.getString("About"));
        mItem_about1.setToolTipText(langBundle.getString("TT_About"));
        mItem_about1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mItem_about1ActionPerformed(evt);
            }
        });
        contextMenuOptions.add(mItem_about1);

        mItem_exit1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/door_out.png"))); // NOI18N
        mItem_exit1.setText(langBundle.getString("Exit"));
        mItem_exit1.setToolTipText(langBundle.getString("TT_Exit"));
        mItem_exit1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mItem_exit1ActionPerformed(evt);
            }
        });
        contextMenuOptions.add(mItem_exit1);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle(langBundle.getString("FrameTitle"));
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                handleWindowClosing(evt);
            }
        });

        toolbar.setFloatable(false);
        toolbar.setRollover(true);
        toolbar.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        btn_newFile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/page.png"))); // NOI18N
        btn_newFile.setMnemonic('N');
        btn_newFile.setText(langBundle.getString("NewFile"));
        btn_newFile.setToolTipText(langBundle.getString("TT_NewFile"));
        btn_newFile.setFocusable(false);
        btn_newFile.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btn_newFile.setPreferredSize(new java.awt.Dimension(40, 41));
        btn_newFile.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btn_newFile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_newFileActionPerformed(evt);
            }
        });
        toolbar.add(btn_newFile);

        btn_openFile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/folder_page.png"))); // NOI18N
        btn_openFile.setText(langBundle.getString("OpenFile"));
        btn_openFile.setToolTipText(langBundle.getString("TT_OpenFile"));
        btn_openFile.setFocusable(false);
        btn_openFile.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btn_openFile.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btn_openFile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_openFileActionPerformed(evt);
            }
        });
        toolbar.add(btn_openFile);

        btn_save.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/page_save.png"))); // NOI18N
        btn_save.setText(langBundle.getString("SaveFile"));
        btn_save.setToolTipText(langBundle.getString("TT_SaveFile"));
        btn_save.setFocusable(false);
        btn_save.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btn_save.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btn_save.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_saveActionPerformed(evt);
            }
        });
        toolbar.add(btn_save);

        btn_saveAs.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/page_save.png"))); // NOI18N
        btn_saveAs.setText(langBundle.getString("SaveAs"));
        btn_saveAs.setToolTipText(langBundle.getString("TT_SaveFileAs"));
        btn_saveAs.setFocusable(false);
        btn_saveAs.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btn_saveAs.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btn_saveAs.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_saveAsActionPerformed(evt);
            }
        });
        toolbar.add(btn_saveAs);

        btn_close.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/page_delete.png"))); // NOI18N
        btn_close.setText(langBundle.getString("CloseFile"));
        btn_close.setToolTipText(langBundle.getString("TT_CloseFile"));
        btn_close.setFocusable(false);
        btn_close.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btn_close.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btn_close.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_closeActionPerformed(evt);
            }
        });
        toolbar.add(btn_close);
        toolbar.add(filler2);

        btn_undo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/arrow_undo.png"))); // NOI18N
        btn_undo.setText(langBundle.getString("Undo"));
        btn_undo.setToolTipText(langBundle.getString("TT_Undo"));
        btn_undo.setFocusable(false);
        btn_undo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btn_undo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btn_undo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_undoActionPerformed(evt);
            }
        });
        toolbar.add(btn_undo);

        btn_redo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/arrow_redo.png"))); // NOI18N
        btn_redo.setText(langBundle.getString("Redo"));
        btn_redo.setToolTipText(langBundle.getString("TT_Redo"));
        btn_redo.setFocusable(false);
        btn_redo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btn_redo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btn_redo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_redoActionPerformed(evt);
            }
        });
        toolbar.add(btn_redo);
        toolbar.add(filler3);

        btn_copy.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/page_copy.png"))); // NOI18N
        btn_copy.setText(langBundle.getString("Copy"));
        btn_copy.setToolTipText(langBundle.getString("TT_Copy"));
        btn_copy.setFocusable(false);
        btn_copy.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btn_copy.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btn_copy.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_copyActionPerformed(evt);
            }
        });
        toolbar.add(btn_copy);

        btn_paste.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/page_paste.png"))); // NOI18N
        btn_paste.setText(langBundle.getString("Paste"));
        btn_paste.setToolTipText(langBundle.getString("TT_Paste"));
        btn_paste.setFocusable(false);
        btn_paste.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btn_paste.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btn_paste.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_pasteActionPerformed(evt);
            }
        });
        toolbar.add(btn_paste);
        toolbar.add(filler4);
        toolbar.add(filler6);

        btn_convertUml.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/style_edit.png"))); // NOI18N
        btn_convertUml.setText(langBundle.getString("umlaut"));
        btn_convertUml.setToolTipText(langBundle.getString("TT_Paste"));
        btn_convertUml.setFocusable(false);
        btn_convertUml.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btn_convertUml.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btn_convertUml.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_convertUmlActionPerformed(evt);
            }
        });
        toolbar.add(btn_convertUml);
        toolbar.add(filler11);
        toolbar.add(filler12);

        btn_startBooAction.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/html.png"))); // NOI18N
        btn_startBooAction.setText(langBundle.getString("Compile"));
        btn_startBooAction.setToolTipText(langBundle.getString("TT_StartCompiler"));
        btn_startBooAction.setFocusable(false);
        btn_startBooAction.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btn_startBooAction.setMaximumSize(new java.awt.Dimension(100, 30));
        btn_startBooAction.setMinimumSize(new java.awt.Dimension(40, 30));
        btn_startBooAction.setPreferredSize(new java.awt.Dimension(100, 30));
        btn_startBooAction.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btn_startBooAction.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_startBooActionActionPerformed(evt);
            }
        });
        toolbar.add(btn_startBooAction);

        btn_uploadAction.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/html_go.png"))); // NOI18N
        btn_uploadAction.setText(langBundle.getString("Upload"));
        btn_uploadAction.setToolTipText(langBundle.getString("TT_StartCompiler"));
        btn_uploadAction.setFocusable(false);
        btn_uploadAction.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btn_uploadAction.setMaximumSize(new java.awt.Dimension(100, 30));
        btn_uploadAction.setMinimumSize(new java.awt.Dimension(40, 30));
        btn_uploadAction.setPreferredSize(new java.awt.Dimension(100, 30));
        btn_uploadAction.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btn_uploadAction.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_uploadActionActionPerformed(evt);
            }
        });
        toolbar.add(btn_uploadAction);
        toolbar.add(filler1);

        btn_options.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/cog.png"))); // NOI18N
        btn_options.setText(langBundle.getString("Options"));
        btn_options.setToolTipText(langBundle.getString("TT_Optionen"));
        btn_options.setFocusable(false);
        btn_options.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btn_options.setMaximumSize(new java.awt.Dimension(107, 41));
        btn_options.setMinimumSize(new java.awt.Dimension(107, 41));
        btn_options.setPreferredSize(new java.awt.Dimension(107, 41));
        btn_options.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btn_options.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                btn_optionsMousePressed(evt);
            }
        });
        toolbar.add(btn_options);

        getContentPane().add(toolbar, java.awt.BorderLayout.PAGE_START);

        panelStatusBar.setPreferredSize(new java.awt.Dimension(792, 20));
        panelStatusBar.setLayout(new java.awt.BorderLayout());

        lbl_statusbarFilePath.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lbl_statusbarFilePath.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/information.png"))); // NOI18N
        lbl_statusbarFilePath.setText(langBundle.getString("StatusbarWelcome"));
        panelStatusBar.add(lbl_statusbarFilePath, java.awt.BorderLayout.CENTER);

        getContentPane().add(panelStatusBar, java.awt.BorderLayout.SOUTH);

        jSplitPane1.setDividerSize(6);

        jPanel1.setLayout(new java.awt.BorderLayout());
        jPanel1.add(filler14, java.awt.BorderLayout.PAGE_START);

        tabEditorDocuments.setMinimumSize(new java.awt.Dimension(500, 5));
        tabEditorDocuments.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                handleEventTabChanged(evt);
            }
        });
        jPanel1.add(tabEditorDocuments, java.awt.BorderLayout.CENTER);

        jSplitPane1.setLeftComponent(jPanel1);

        jPanel2.setLayout(new java.awt.BorderLayout());
        jPanel2.add(filler15, java.awt.BorderLayout.PAGE_START);
        jPanel2.add(browserTab, java.awt.BorderLayout.CENTER);

        jSplitPane1.setRightComponent(jPanel2);

        getContentPane().add(jSplitPane1, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btn_newFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_newFileActionPerformed
        this.handleNewFileAction();
    }//GEN-LAST:event_btn_newFileActionPerformed

    private void btn_openFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_openFileActionPerformed
        this.handleOpenFileAction();
    }//GEN-LAST:event_btn_openFileActionPerformed

    private void btn_saveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_saveActionPerformed
        this.handleSaveFileAction();

    }//GEN-LAST:event_btn_saveActionPerformed

    private void btn_startBooActionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_startBooActionActionPerformed

        this.handleSaveFileAction();
        this.activeTab.showHtmlPreview();


    }//GEN-LAST:event_btn_startBooActionActionPerformed

    private void btn_copyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_copyActionPerformed
        this.activeTab.handleCopy();
    }//GEN-LAST:event_btn_copyActionPerformed

    private void btn_pasteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_pasteActionPerformed
        this.activeTab.handlePaste();
    }//GEN-LAST:event_btn_pasteActionPerformed

    private void handleWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_handleWindowClosing
        this.saveNewViewSettings();
        //SettingsManager.writeSettingsToFile();
        this.handleCloseFileAction();
    }//GEN-LAST:event_handleWindowClosing

    private void btn_undoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_undoActionPerformed
        if (this.activeTab.handleCanUndo()) {
            this.activeTab.handleUndoLastAction();
        }
    }//GEN-LAST:event_btn_undoActionPerformed

    private void btn_redoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_redoActionPerformed
        if (this.activeTab.handleCanRedo()) {
            this.activeTab.handleRedoLastAction();
        }
    }//GEN-LAST:event_btn_redoActionPerformed

    private void handleEventTabChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_handleEventTabChanged

        this.activeTab = (CustomTabPanel) this.tabEditorDocuments.getSelectedComponent();
        if (this.activeTab.isSavedFile()) {
            this.setInfoTextStatusBar(langBundle.getString("File") + ": " + this.activeTab.getFilePath());
        } else {
            this.setInfoTextStatusBar(langBundle.getString("MsgInfoNewFile"));
        }


    }//GEN-LAST:event_handleEventTabChanged

    private void btn_closeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_closeActionPerformed
        this.handleCloseTab();
    }//GEN-LAST:event_btn_closeActionPerformed

    private void btn_uploadActionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_uploadActionActionPerformed
        this.activeTab.showHtmlInBrowser();
    }//GEN-LAST:event_btn_uploadActionActionPerformed

    private void mItem_newFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mItem_newFileActionPerformed
        this.handleNewFileAction();
    }//GEN-LAST:event_mItem_newFileActionPerformed

    private void mItem_openFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mItem_openFileActionPerformed
        this.handleOpenFileAction();
    }//GEN-LAST:event_mItem_openFileActionPerformed

    private void mItem_closeFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mItem_closeFileActionPerformed
        this.handleCloseTab();
    }//GEN-LAST:event_mItem_closeFileActionPerformed

    private void mItem_saveFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mItem_saveFileActionPerformed
        this.handleSaveFileAction();
    }//GEN-LAST:event_mItem_saveFileActionPerformed

    private void mItem_saveFileAsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mItem_saveFileAsActionPerformed
        this.handleSaveFileAsAction();
    }//GEN-LAST:event_mItem_saveFileAsActionPerformed

    private void mItem_printFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mItem_printFileActionPerformed
        try {
            this.activeTab.handlePrint();
        } catch (PrinterException ex) {
            GuiManager.getInstance().showErrorMessage(langBundle.getString("MsgErrorPrint"));
            Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
            System.err.println("Error, printing document failed: " + ex.toString());
        }
    }//GEN-LAST:event_mItem_printFileActionPerformed

    private void mItem_exitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mItem_exitActionPerformed
        this.saveNewViewSettings();
        //SettingsManager.writeSettingsToFile();
        this.dispose();
        System.exit(0);
    }//GEN-LAST:event_mItem_exitActionPerformed

    private void menu_undoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menu_undoActionPerformed
        this.activeTab.handleUndoLastAction();
    }//GEN-LAST:event_menu_undoActionPerformed

    private void menu_redoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menu_redoActionPerformed
        this.activeTab.handleRedoLastAction();
    }//GEN-LAST:event_menu_redoActionPerformed

    private void menu_copyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menu_copyActionPerformed
        this.activeTab.handleCopy();
    }//GEN-LAST:event_menu_copyActionPerformed

    private void menu_pasteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menu_pasteActionPerformed
        this.activeTab.handlePaste();
    }//GEN-LAST:event_menu_pasteActionPerformed

    private void menu_cutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menu_cutActionPerformed
        this.activeTab.handleCut();
    }//GEN-LAST:event_menu_cutActionPerformed

    private void menu_selectAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menu_selectAllActionPerformed
        this.activeTab.handleSelectAll();
    }//GEN-LAST:event_menu_selectAllActionPerformed

    private void mItem_aboutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mItem_aboutActionPerformed
        new InfoDialog(this, true).setVisible(true);
    }//GEN-LAST:event_mItem_aboutActionPerformed

    private void mItem_helpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mItem_helpActionPerformed
        Desktop desk = Desktop.getDesktop();
        try {
            File f = new File(System.getProperty("user.dir") + File.separator + "readme.html");
            desk.open(f);
        } catch (Exception ex) {
            Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
            GuiManager.getInstance().showErrorMessage(langBundle.getString("MsgErrorOpenHelp"));
            System.err.println("Error beim Öffnen der Hilfedatei");
        }
    }//GEN-LAST:event_mItem_helpActionPerformed

    private void btn_convertUmlActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_convertUmlActionPerformed
        this.activeTab.textEditor.convertUmlForHTML();
    }//GEN-LAST:event_btn_convertUmlActionPerformed

    private void btn_optionsMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_optionsMousePressed
        this.contextMenuOptions.show(evt.getComponent(), evt.getX(), evt.getY());
        this.contextMenuOptions.setVisible(true);
    }//GEN-LAST:event_btn_optionsMousePressed

    private void mItem_printFile1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mItem_printFile1ActionPerformed
        try {
            this.activeTab.handlePrint();
        } catch (PrinterException ex) {
            GuiManager.getInstance().showErrorMessage(langBundle.getString("MsgErrorPrint"));
            Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
            System.err.println("Error, printing document failed: " + ex.toString());
        }
    }//GEN-LAST:event_mItem_printFile1ActionPerformed

    private void mItem_exit1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mItem_exit1ActionPerformed
        this.saveNewViewSettings();
        //SettingsManager.writeSettingsToFile();
        this.dispose();
        System.exit(0);
    }//GEN-LAST:event_mItem_exit1ActionPerformed

    private void mItem_EditorOptionsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mItem_EditorOptionsActionPerformed
        this.saveNewViewSettings();
        new OptionsDialog(this, true, GuiManager.getInstance());
    }//GEN-LAST:event_mItem_EditorOptionsActionPerformed

    private void mItemBigFontActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mItemBigFontActionPerformed
        GuiManager.setBigScreenModus(!GuiManager.bigScreenModus());
        if (GuiManager.bigScreenModus()) {
            this.mItemBigFont.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/magifier_zoom_out.png")));
        } else {
            this.mItemBigFont.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/magnifier.png")));
        }

        GuiManager.getInstance().updateGui();
    }//GEN-LAST:event_mItemBigFontActionPerformed

    private void mItem_about1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mItem_about1ActionPerformed
        new InfoDialog(this, true).setVisible(true);
    }//GEN-LAST:event_mItem_about1ActionPerformed

    private void btn_saveAsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_saveAsActionPerformed
        this.handleSaveFileAsAction();
    }//GEN-LAST:event_btn_saveAsActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTabbedPane browserTab;
    private javax.swing.JButton btn_close;
    private javax.swing.JButton btn_convertUml;
    private javax.swing.JButton btn_copy;
    private javax.swing.JButton btn_newFile;
    private javax.swing.JButton btn_openFile;
    private javax.swing.JButton btn_options;
    private javax.swing.JButton btn_paste;
    private javax.swing.JButton btn_redo;
    private javax.swing.JButton btn_save;
    private javax.swing.JButton btn_saveAs;
    private javax.swing.JButton btn_startBooAction;
    private javax.swing.JButton btn_undo;
    private javax.swing.JButton btn_uploadAction;
    private javax.swing.JPopupMenu contextMenuOptions;
    private javax.swing.Box.Filler filler1;
    private javax.swing.Box.Filler filler11;
    private javax.swing.Box.Filler filler12;
    private javax.swing.Box.Filler filler14;
    private javax.swing.Box.Filler filler15;
    private javax.swing.Box.Filler filler2;
    private javax.swing.Box.Filler filler3;
    private javax.swing.Box.Filler filler4;
    private javax.swing.Box.Filler filler6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPopupMenu jPopupMenu1;
    private javax.swing.JPopupMenu.Separator jSeparator3;
    private javax.swing.JPopupMenu.Separator jSeparator4;
    private javax.swing.JPopupMenu.Separator jSeparator5;
    private javax.swing.JSplitPane jSplitPane1;
    private javax.swing.JLabel lbl_statusbarFilePath;
    private javax.swing.JMenuItem mItemBigFont;
    private javax.swing.JMenuItem mItem_EditorOptions;
    private javax.swing.JMenuItem mItem_about;
    private javax.swing.JMenuItem mItem_about1;
    private javax.swing.JMenuItem mItem_closeFile;
    private javax.swing.JMenuItem mItem_exit;
    private javax.swing.JMenuItem mItem_exit1;
    private javax.swing.JMenuItem mItem_help;
    private javax.swing.JMenuItem mItem_newFile;
    private javax.swing.JMenuItem mItem_openFile;
    private javax.swing.JMenuItem mItem_printFile;
    private javax.swing.JMenuItem mItem_printFile1;
    private javax.swing.JMenuItem mItem_saveFile;
    private javax.swing.JMenuItem mItem_saveFileAs;
    private javax.swing.JMenu menu_Edit;
    private javax.swing.JMenu menu_Edit1;
    private javax.swing.JMenu menu_File1;
    private javax.swing.JMenu menu_Help;
    private javax.swing.JMenuItem menu_copy;
    private javax.swing.JMenuItem menu_cut;
    private javax.swing.JMenuItem menu_paste;
    private javax.swing.JMenuItem menu_redo;
    private javax.swing.JMenuItem menu_selectAll;
    private javax.swing.JMenuItem menu_undo;
    private javax.swing.JPanel panelStatusBar;
    private javax.swing.JTabbedPane tabEditorDocuments;
    private javax.swing.JToolBar toolbar;
    // End of variables declaration//GEN-END:variables

    private void handleCloseTab() {

        if (this.tabEditorDocuments.getSelectedIndex() == 0) {
            this.handleNewFileAction();
            this.tabEditorDocuments.remove(0);
        } else {
            this.tabEditorDocuments.remove(this.tabEditorDocuments.getSelectedIndex());
            this.activeTab = (CustomTabPanel) this.tabEditorDocuments.getSelectedComponent();

        }


    }

    private void handleSaveFileAsAction() {
        this.activeTab.handleSaveFileAs();
    }

    public void renderHtmlFile() {
        File f = new File(this.activeTab.getFilePath());
        if (FileManager.hasHtmlExtension(f)) {
            try {
                //@todo this.customHtmlBrowser1.setHtmlFile(fileFullPath, new File(this.activeTab.getFilePath()));

                this.browser.clear();
                this.browser.navigate(f.toURI().toURL());

                this.browserTab.setTitleAt(0, "Vorschau: " + this.browser.getCurrentNavigationEntry().getTitle());
                this.validate();

            } catch (MalformedURLException ex) {
                Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
            }

        }
    }
    
}  

